package com.eslserver.to;

import java.util.Collection;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;

@Entity
@Proxy(lazy = false)
@Table(name = "ESL")
public class ESL {

	private Integer ESLID;
	private Group group;
	private Coordinator coordinator;
	private Collection<Image> images;
	private Collection<Schedule> schedules;
	private String name;
	private String description;
	private String macAddress;
	private Boolean delete;
	private Date createDate;
	private Date modifyDate;

	public ESL() {
	};

	public static ESL createESL() {
		ESL esl = new ESL();
		esl.setDelete(false);
		return esl;
	}

	@Id
	@Column(name = "esl_id")
	@GeneratedValue(generator = "increment")
	@GenericGenerator(name = "increment", strategy = "increment")
	public Integer getESLID() {
		return ESLID;
	}

	public void setESLID(Integer eSLID) {
		ESLID = eSLID;
	}

	@ManyToOne
	@JoinColumn(name = "group_id_fk")
	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	@ManyToOne
	@JoinColumn(name = "coordinator_id_fk")
	public Coordinator getCoordinator() {
		return coordinator;
	}

	public void setCoordinator(Coordinator coordinator) {
		this.coordinator = coordinator;
	}

	@OneToMany
	@Fetch(FetchMode.SELECT)
	@JoinTable(name = "ESL_IMAGE_LU", joinColumns = @JoinColumn(name = "esl_id_fk"), inverseJoinColumns = @JoinColumn(name = "esl_image_id_fk"))
	@OrderBy("imageID DESC")
	public Collection<Image> getImages() {
		return images;
	}

	public void setImages(Collection<Image> images) {
		this.images = images;
	}

	@OneToMany(mappedBy = "esl")
	@Fetch(FetchMode.SELECT)
	public Collection<Schedule> getSchedules() {
		return schedules;
	}

	public void setSchedules(Collection<Schedule> schedules) {
		this.schedules = schedules;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "mac_address")
	public String getMacAddress() {
		return macAddress;
	}

	public void setMacAddress(String macAddress) {
		this.macAddress = macAddress;
	}

	@Column(name = "isDelete")
	public Boolean isDelete() {
		return delete;
	}

	public void setDelete(Boolean delete) {
		this.delete = delete;
	}

	@Column(name = "create_date")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Column(name = "modify_date")
	public Date getModifyDate() {
		return modifyDate;
	}

	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}

}
